package cn.edu.scau.dropship.mapper;

import cn.edu.scau.dropship.entity.Goods;
import cn.edu.scau.dropship.entity.Order_goods;
import cn.edu.scau.dropship.entity.Order_goodsExample;
import cn.edu.scau.dropship.entity.Order_goodsKey;
import java.util.List;
import org.apache.ibatis.annotations.Arg;
import org.apache.ibatis.annotations.ConstructorArgs;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.DeleteProvider;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.InsertProvider;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.SelectProvider;
import org.apache.ibatis.annotations.Update;
import org.apache.ibatis.annotations.UpdateProvider;
import org.apache.ibatis.type.JdbcType;

public interface Order_goodsMapper {
    @SelectProvider(type=Order_goodsSqlProvider.class, method="countByExample")
    long countByExample(Order_goodsExample example);

    @DeleteProvider(type=Order_goodsSqlProvider.class, method="deleteByExample")
    int deleteByExample(Order_goodsExample example);

    @Delete({
        "delete from order_goods",
        "where goods_id = #{goodsId,jdbcType=INTEGER}",
          "and order_id = #{orderId,jdbcType=INTEGER}"
    })
    int deleteByPrimaryKey(Order_goodsKey key);

    @Insert({
        "insert into order_goods (goods_id, order_id, ",
        "goods_num)",
        "values (#{goodsId,jdbcType=INTEGER}, #{orderId,jdbcType=INTEGER}, ",
        "#{goodsNum,jdbcType=INTEGER})"
    })
    int insert(Order_goods record);

    @InsertProvider(type=Order_goodsSqlProvider.class, method="insertSelective")
    int insertSelective(Order_goods record);

    @SelectProvider(type=Order_goodsSqlProvider.class, method="selectByExample")
    @ConstructorArgs({
        @Arg(column="goods_id", javaType=Integer.class, jdbcType=JdbcType.INTEGER, id=true),
        @Arg(column="order_id", javaType=Integer.class, jdbcType=JdbcType.INTEGER, id=true),
        @Arg(column="goods_num", javaType=Integer.class, jdbcType=JdbcType.INTEGER)
    })
    List<Order_goods> selectByExample(Order_goodsExample example);

    @Select({
        "select",
        "goods_id, order_id, goods_num",
        "from order_goods",
        "where goods_id = #{goodsId,jdbcType=INTEGER}",
          "and order_id = #{orderId,jdbcType=INTEGER}"
    })
    @ConstructorArgs({
        @Arg(column="goods_id", javaType=Integer.class, jdbcType=JdbcType.INTEGER, id=true),
        @Arg(column="order_id", javaType=Integer.class, jdbcType=JdbcType.INTEGER, id=true),
        @Arg(column="goods_num", javaType=Integer.class, jdbcType=JdbcType.INTEGER)
    })
    Order_goods selectByPrimaryKey(Order_goodsKey key);

    @UpdateProvider(type=Order_goodsSqlProvider.class, method="updateByExampleSelective")
    int updateByExampleSelective(@Param("record") Order_goods record, @Param("example") Order_goodsExample example);

    @UpdateProvider(type=Order_goodsSqlProvider.class, method="updateByExample")
    int updateByExample(@Param("record") Order_goods record, @Param("example") Order_goodsExample example);

    @UpdateProvider(type=Order_goodsSqlProvider.class, method="updateByPrimaryKeySelective")
    int updateByPrimaryKeySelective(Order_goods record);

    @Update({
        "update order_goods",
        "set goods_num = #{goodsNum,jdbcType=INTEGER}",
        "where goods_id = #{goodsId,jdbcType=INTEGER}",
          "and order_id = #{orderId,jdbcType=INTEGER}"
    })
    int updateByPrimaryKey(Order_goods record);

    @Select("select goods.* from `orders` , order_goods , goods where `orders`.id = order_goods.order_id  and order_goods.goods_id = goods.id and  order_id = #{id}")
    @ConstructorArgs({
            @Arg(column="id", javaType=Integer.class, jdbcType=JdbcType.INTEGER, id=true),
            @Arg(column="title", javaType=String.class, jdbcType=JdbcType.VARCHAR),
            @Arg(column="length", javaType=Double.class, jdbcType=JdbcType.DOUBLE),
            @Arg(column="width", javaType=Double.class, jdbcType=JdbcType.DOUBLE),
            @Arg(column="height", javaType=Double.class, jdbcType=JdbcType.DOUBLE),
            @Arg(column="weight", javaType=Double.class, jdbcType=JdbcType.DOUBLE),
            @Arg(column="sku", javaType=String.class, jdbcType=JdbcType.VARCHAR),
            @Arg(column="upc", javaType=String.class, jdbcType=JdbcType.VARCHAR),
            @Arg(column="ena", javaType=String.class, jdbcType=JdbcType.VARCHAR),
            @Arg(column="model", javaType=String.class, jdbcType=JdbcType.VARCHAR),
            @Arg(column="price", javaType=Double.class, jdbcType=JdbcType.DOUBLE),
            @Arg(column="warranty_time", javaType=String.class, jdbcType=JdbcType.VARCHAR),
            @Arg(column="ebay_description", javaType=String.class, jdbcType=JdbcType.VARCHAR),
            @Arg(column="amazon_description", javaType=String.class, jdbcType=JdbcType.VARCHAR),
            @Arg(column="image", javaType=String.class, jdbcType=JdbcType.VARCHAR),
            @Arg(column="state", javaType=String.class, jdbcType=JdbcType.VARCHAR),
            @Arg(column="classification_id", javaType=Integer.class, jdbcType=JdbcType.INTEGER),
            @Arg(column="brand_id", javaType=Integer.class, jdbcType=JdbcType.INTEGER)
    })
    List<Goods> selectGoodByOrderID(Integer id);

}